﻿using JavaDevToys.Rcl.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace JavaDevToys.Rcl.Service.Impl
{
    public class SettingService : ISettingService
    {
        public ExInterfaceSetting GetInterfaceSetting()
        {
            throw new NotImplementedException();
        }

        public Dictionary<string, string> GetInterfaceTypeMapping()
        {
            throw new NotImplementedException();
        }

        public SettingInfo GetSettings()
        {
            string json=string.Empty;
            using (StreamReader sr = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/Settings.Json"), Encoding.UTF8))
            {
                json = sr.ReadToEnd();
            }
            return JsonSerializer.Deserialize<SettingInfo>(json);
        }

        public SettingInfo GetSettings(int projectType)
        {
            SettingInfo settingInfo= GetSettings();
            settingInfo.JavaProjectInfoList = settingInfo.JavaProjectInfoList.Where(w=>w.ProjectType==projectType).ToList();
            return settingInfo;
        }

        public void SaveInterfaceSetting(ExInterfaceSetting exInterfaceSetting)
        {
            throw new NotImplementedException();
        }

        public void SaveSettings(SettingInfo settingInfo)
        {
            throw new NotImplementedException();
        }
    }
}
